package com.central.product.service.serviceImp

import cn.hutool.core.bean.BeanUtil
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.central.common.entity.DrawProduct
import com.central.common.service.impl.SuperServiceImpl
import com.central.product.mapper.DrawProductMapper
import com.central.product.pojo.drawProductGroup.DrawProductVo
import com.central.product.service.DrawProductService
import org.springframework.stereotype.Service

/**
 * @author  fly
 * @date  2021/5/26 14:53
 * @version 1.0
 */
@Service
open class DrawProductServiceImp : SuperServiceImpl<DrawProductMapper, DrawProduct>(), DrawProductService {


    override fun getDrawProductVoByProductGroupId(groupId: Long): List<DrawProductVo>? =
        list(KtQueryWrapper(DrawProduct::class.java)
            .eq(DrawProduct::drawProductGroupId, groupId))
            .takeIf { it.isNotEmpty() }
            ?.run { mapNotNull { DrawProductVo().apply { BeanUtil.copyProperties(it, this) } } }

}
